<%@ page import="com.wuchao.service.serviceImpl.ServiceImpl" %>
<%@ page import="com.wuchao.entity.User" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        .bianse{
            color: red;
        }
    </style>
</head>
<body>
<h1>欢迎分页</h1>
<table border="4">
    <tr>
        <th>id</th>
        <th>name</th>
        <th>sex</th>
        <th>hobby</th>
    </tr>
    <%
        int currentPage=1;//核心就他要变 当前页码
        int pageSize=2;//每页展示数
        if(request.getParameter("currentPage")!=null){
            currentPage= Integer.parseInt(request.getParameter("currentPage"));//页码轮换
        }
        ServiceImpl service = new ServiceImpl();
        int totals = service.isLoading("select count(1) from user");//总条数
        int pageMax=totals%pageSize==0?totals/pageSize:totals/pageSize+1;//总页数
        int pageMin=1;
        List<User> list= service.findPoJo("select  * from user limit ?,?",(currentPage-1)*pageSize,pageSize);
        for(User xjj : list){%>
    <tr>
        <td><%=xjj.getId()%></td>
        <td><%=xjj.getName()%></td>
        <td><%=xjj.getSex()%></td>
        <td><%=xjj.getHobby()%></td>
    </tr>
        <%} %>
</table>
<p><% for(int i=1;i<=pageMax;i++){%>
        <a  <%=currentPage==i?"class=\"bianse\"":""%> href="../page/page.jsp?currentPage=<%=i%>"><%=i%></a>
    <%}%>
  <%--  <input type="text" ><a href="../page/page.jsp?currentPage=1">请输入搜索页，大于最大页默认最大页</a>--%>
</p>
<span><%=currentPage%>/<%=pageMax%>当前页/总页数</span>
<a href="../page/page.jsp?currentPage=1">首页</a>
<a href="../page/page.jsp?currentPage=<%=currentPage-1<=1?1:currentPage-1%>" <%=currentPage<=1?"hidden":""%> >上一页</a>
<a href="../page/page.jsp?currentPage=<%=currentPage+1>=pageMax?pageMax:currentPage+1%>" <%=currentPage>=pageMax?"hidden":""%>>下一页</a>
<a href="../page/page.jsp?currentPage=<%=pageMax%>">尾页</a>



<script src="../js/jquery.js"></script>
<script>

</script>
</body>
</html>
